<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" name="" id="ipt">
    <button id="btn">
        点击添加
    </button></br>
    <span id="num">

    </span>
    <script>
        var arr = [5, 8, 20, 32, 35]
        num.innerHTML = arr;
        btn.onclick = function () {
            var n = ipt.value;
            arr.push(n);
            arr.sort(function (a, b) {
                return a - b
            });
            num.innerHTML = arr
        }

    </script>
</body>

</html>